" 修改leader键
let mapleader = "\<space>"
let g:mapleader ="\<space>"
        " ii 替换 Esc
inoremap ii <Esc>
        " 将 ; 绑定到 : 用于快速进入命令行
nnoremap ; :
" 保证工作目录为当前目录
autocmd BufEnter * lcd %:p:h


" ##### 插件配置
if filereadable(expand("$VIM_TMP_PATH/vimrc.bundles"))
    source $VIM_TMP_PATH/vimrc.bundles
endif

" ##### 基本配置
if filereadable(expand("$VIM_CONFIG_PATH/vimrc.config_base"))
    source $VIM_CONFIG_PATH/vimrc.config_base
endif

" #####  文件类型设置
if filereadable(expand("$VIM_CONFIG_PATH/vimrc.config_filetype"))
    source $VIM_CONFIG_PATH/vimrc.config_filetype
endif

" ##### 项目自定义配置
" ##### 如果当前项目文件内有关于 vim  的特殊配置，
if filereadable(expand("$VIM_CONFIG_PATH/vimrc.workspace"))
    source $VIM_CONFIG_PATH/vimrc.workspace
endif

" ##### 本地自定义配置
if filereadable(expand("$HOME/vimrc.local"))
    source $HOME/vimrc.local
endif

" ##### 各种 vim 文件设置
" 备份
set backup
set backupdir=$VIM_TMP_PATH/vimbackup

set viewdir=$VIM_TMP_PATH/vimview
" 备份防相同文件名：
autocmd BufWritePre *
    \ let s:cmd = 'echo '. '"' . expand("%:p") . '"|base64' |
    \ let s:cmd = substitute(system(s:cmd),"\n","","") |
    \ let &bex = '_' . strftime("%Y%m%d") . '_' . s:cmd |
    \ exe ":mkview"
" 查找备份的解码, 放在 bash_alias.sh 中
" alias lsvimbak="ls*|rev|cut -d_  -f1 |rev|base64 -D"


" 交换文件
set swapfile
set dir=$VIM_TMP_PATH/vimswap

" undo
if has('persistent_undo')
    set undolevels=1000         " How many undos
    set undoreload=10000        " number of lines to save for undo
    set undofile                " So is persistent undo ...
    set undodir=$VIM_TMP_PATH/vimundo
endif


